﻿using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;

namespace MarkupSanitizer.Tests
{
    [TestFixture]
    public class MarkupWriterTests
    {
        [Test]
        public void ShouldStoreOpenTagsAsLastInFirstOut()
        {
            var markupWriter = new MarkupWriter(GetTestAllowedTags());
            markupWriter.OpenTag(new TagDefinition("p", false), null);
            markupWriter.OpenTag(new TagDefinition("strong", false), null);

            Assert.AreEqual("strong", markupWriter.OpenTags.First());
        }

        private IDictionary<string, TagDefinition> GetTestAllowedTags()
        {
            return new Dictionary<string, TagDefinition>(StringComparer.InvariantCultureIgnoreCase)
                                  {
                                      {"p", new TagDefinition("p", false)},
                                      {"strong", new TagDefinition("strong", false)}
                                  };
        }
    }
}
